<template>
  <div class="SearchView">
    <!-- 顶部标题 -->
    <top-title-bar>
      <template #left>
        <div class="left" @click="$router.go(-1)">
          <span class="iconfont icon-xiangzuo1"></span>
        </div>
      </template>
      <template #middle>
        <div class="middle" v-if="model == 0">
          <van-swipe
            class="inp"
            :autoplay="0"
            indicator-color="white"
            :show-indicators="false"
            :touchable="false"
            :vertical="true"
            ref="search"
          >
            <van-swipe-item>
              <input
                type="text"
                placeholder="输入帖子名称 / 关键字"
                maxlength="11"
                v-model="keywordPost"
            /></van-swipe-item>
            <van-swipe-item>
              <input
                type="text"
                placeholder="搜索用户功能--暂未开放"
                maxlength="11"
                v-model="keywordUser"
            /></van-swipe-item>
          </van-swipe>
          <del
            class="iconfont icon-guanbi"
            v-show="
              active == 0 ? keywordPost.length > 0 : keywordUser.length > 0
            "
            @click="clearInputFun"
          ></del>
        </div>
        <div class="middle" v-if="model == 1">
          <div class="inp">
            <!-- placeholder="找游戏 认准 葫王" -->
            <input
              type="text"
              v-model="keywordGame"
              placeholder=""
              ref="searchGameInp"
            />
          </div>
          <del
            class="iconfont icon-guanbi"
            v-show="keywordGame.length > 0"
            @click="clearInputFun"
          ></del>
        </div>
      </template>
      <template #right>
        <div class="right" @click="searchFun">
          <span class="iconfont icon-fangdajing"></span>
        </div>
      </template>
    </top-title-bar>
    <!-- post导航栏 -->
    <div class="postNav" v-if="model == 0">
      <van-tabs
        v-model="active"
        offset-top="50px"
        sticky
        swipeable
        duration="1"
        animated
        color="#0cc85c"
        title-active-color="#14ca61"
        title-inactive-color="#666666"
        @change="$refs.search.swipeTo(active)"
      >
        <van-tab title="帖子">
          <div class="search-post-box" @click="changeSearchFlag">
            <p>搜索{{ flag == 0 ? "本" : "全部" }}版块</p>
            <span class="iconfont icon-zhuandao"></span>
          </div>
        </van-tab>
        <van-tab title="用户"> <hr /> </van-tab>
      </van-tabs>
    </div>
    <!-- game热门 -->
    <div class="hot-game" v-if="isSearch && model == 1 && searchRecommendList">
      <div class="game-head">热门搜索</div>
      <div class="game-body">
        <p
          v-for="index in searchRecommendList.keywodList.length"
          :key="index"
          :style="{ color: searchRecommendList.colors[index - 1] }"
          @click="keywordGame = searchRecommendList.keywodList[index - 1]"
        >
          <em>{{ index }}</em
          ><span class="text-ellipsis-1">{{
            searchRecommendList.keywodList[index - 1]
          }}</span>
        </p>
      </div>
    </div>
    <!-- 搜索区 -->
    <div class="wrap" v-show="isSearch">
      <div class="head">
        <!-- - 左边 -->
        <div class="left">
          <h1>搜索历史</h1>
        </div>

        <!-- - 右边 -->
        <div class="right">
          <a
            class="clear iconfont icon-shanchu"
            href=""
            target="_blank"
            @click.prevent="clearSearchListHistory()"
            v-show="
              model == 0
                ? searchPostHistoryList.length
                : searchGameHistoryList.length
            "
            >清空</a
          >
        </div>
      </div>

      <div class="body">
        <div
          class="history-item"
          v-for="keyword in model == 0
            ? searchPostHistoryList
            : searchGameHistoryList"
          :key="keyword"
          @click="
            model == 0 ? (keywordPost = keyword) : (keywordGame = keyword)
          "
        >
          <em class="iconfont icon-jurassic_wait"></em>
          <span>{{ keyword }}</span>
          <del
            class="iconfont icon-guanbi"
            @click="clearSearchListHistory(keyword)"
          ></del>
        </div>
      </div>

      <van-empty
        v-show="
          model == 0
            ? !searchPostHistoryList.length
            : !searchGameHistoryList.length
        "
        class="custom-image"
        image="./img/empty.png"
        description="搜索历史为空 搜索看看吧!"
      />
    </div>
    <!-- 搜索结果区 -->
    <div class="wrap" v-show="!isSearch">
      <!-- post显示区 -->
      <div class="post-mag-box" v-if="PostList">
        <div class="body">
          <router-link
            tag="div"
            :to="'/PostDetails?postID=' + post.postID + '&from=技术分享'"
            class="post-item-box"
            v-for="post in PostList.posts"
            :key="post.postID"
          >
            <!-- 没有图片 -->
            <div class="post-item none-pic" v-if="post.images.length == 0">
              <div class="text">
                <div
                  class="title text-ellipsis-2"
                  v-html="HtmlToText(post.title)"
                ></div>

                <div class="content">
                  <span
                    class="text-ellipsis-2"
                    v-html="HtmlToText(post.detail)"
                  >
                  </span>
                </div>

                <div class="info">
                  <div class="left">
                    <div class="name">
                      <small>{{ post.user.nick }}</small>
                    </div>

                    <div class="time">
                      <small>{{ post.createTime | numToDate }}</small>
                    </div>
                  </div>

                  <div class="right">
                    <div class="seek">
                      <i></i
                      ><small class="iconfont icon-kanguo_S">{{
                        post.hit
                      }}</small>
                    </div>

                    <div class="msg">
                      <i></i
                      ><small class="iconfont icon-xiaoxi1">{{
                        post.commentCount
                      }}</small>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- 只有一张图 -->
            <div class="post-item one-pic" v-if="post.images.length == 1">
              <div class="icon"><img :src="post.images[0]" alt="" /></div>

              <div class="text">
                <div class="title text-ellipsis-1" v-html="post.title"></div>

                <div class="content">
                  <span class="text-ellipsis-3" v-html="post.detail"> </span>
                </div>

                <div class="info">
                  <div class="left">
                    <div class="name">
                      <small>{{ post.user.nick }}</small>
                    </div>

                    <div class="time">
                      <small>{{ post.createTime | numToDate }}</small>
                    </div>
                  </div>

                  <div class="right">
                    <div class="seek">
                      <i></i
                      ><small class="iconfont icon-kanguo_S">{{
                        post.hit
                      }}</small>
                    </div>

                    <div class="msg">
                      <i></i
                      ><small class="iconfont icon-xiaoxi1">{{
                        post.commentCount
                      }}</small>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- 两张图以上 -->
            <div class="post-item many-pic" v-if="post.images.length > 1">
              <div class="text">
                <div class="title text-ellipsis-1" v-html="post.title"></div>

                <div class="content">
                  <span
                    class="text-ellipsis-3"
                    v-html="TextToTitle(HtmlToText(post.detail))"
                  >
                  </span>
                </div>

                <div class="imgs" v-if="post.images.length < 3">
                  <div class="img" v-for="img in post.images.length" :key="img">
                    <img :src="post.images[img - 1]" alt="" />
                  </div>
                </div>
                <div class="imgs" v-if="post.images.length >= 3">
                  <div class="img" v-for="img in 3" :key="img">
                    <img :src="post.images[img - 1]" alt="" />
                  </div>
                  <b>{{ post.images.length }}图</b>
                </div>

                <div class="info">
                  <div class="left">
                    <div class="name">
                      <small>{{ post.user.nick }}</small>
                    </div>

                    <div class="time">
                      <small>{{ post.createTime | numToDate }}</small>
                    </div>
                  </div>

                  <div class="right">
                    <div class="seek">
                      <i></i
                      ><small class="iconfont icon-kanguo_S">{{
                        post.hit
                      }}</small>
                    </div>

                    <div class="msg">
                      <i></i
                      ><small class="iconfont icon-xiaoxi1">{{
                        post.commentCount
                      }}</small>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </router-link>
          <van-empty
            v-show="!PostList.posts.length"
            class="custom-image"
            image="./img/empty.png"
            description="去其他地方看看吧!"
          />
        </div>
      </div>
      <!-- game显示区 -->
      <div class="game-box" v-if="GameList">
        <div
          @click="$router.push('/GameDetail?app_id=' + GameList.appid)"
          class="item-flag-0"
          v-for="(item, index) in GameList"
          :key="index"
        >
          <div class="left">
            <div class="img">
              <img :src="item.applogo" alt="" />
            </div>
            <div class="text">
              <h5>{{ item.apptitle }}</h5>
              <p>
                {{
                  item.apptags ? item.apptags.replaceAll(",", " · ") : "游戏"
                }}
              </p>
            </div>
          </div>
          <div class="right">
            <a
              v-if="item.appid % 2 == 0"
              :href="item.appdownul.url"
              target="_blank"
              class="download"
              @click.stop=""
              >下载</a
            >
            <a
              v-if="item.appid % 2 == 1"
              href=""
              target="_blank"
              class="play"
              @click.stop.prevent="$toast('未安装微信\n无法打开小程序')"
              >直接玩</a
            >
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import TopTitleBar from "../components/TopTitleBar.vue";
import { getSearchPostList } from "../assets/api/posts.js";
import { getHomeJson } from "../assets/api/home.js";
export default {
  data() {
    return {
      active: 0, //标签导航的下标
      PostList: null, //数据中心
      isSearch: true, // 是否搜索状态
      flag: 0, // 0为搜索全板块 1为搜索本板块
      keywordPost: "", //关键字
      keywordUser: "", //关键字
      searchPostHistoryList: [], //搜索历史数组

      model: 0, // 搜索模式 0为搜索帖子 1为搜索游戏
      searchRecommendList: null, //热门搜索
      keywordGame: "", //热门搜索输入框
      searchGameHistoryList: [], //搜索历史数组
      GameList: null, //数据中心

      searchGameInp: null, //ref标记节点操作
      searchGameInpInterval: null, //定时器
      searchGameInpPlaceholder: "找游戏 认准 葫王", //提示文字
      searchGameInpPlaceholderLen: 0,
    };
  },
  methods: {
    // 数据初始化
    dataInit() {
      this.model = this.$route.query.model;
      console.log("路由上的参数 搜索模式 model =>", this.model);
      if (this.model == 1) this.__GameInit();
      this.searchHistoryInit();
    },

    // 获取数据
    async __GameInit() {
      // 在请求时
      this.$store.commit("showLoading");
      let data = await getHomeJson();
      this.$toast.success("拉取成功");
      this.searchRecommendList = data.searchRecommendList;
      this.searchGameInpInit();
      console.log("拿到数据", this.searchRecommendList);
      // 请求完成后
      this.$store.commit("hideLoading");
    },

    // 输入框定时器
    searchGameInpInit() {
      this.searchGameInp = this.$refs.searchGameInp;
      this.searchGameInpInterval = setInterval(() => {
        let str = this.searchGameInpPlaceholder;
        this.searchGameInp.placeholder = str.slice(
          0,
          this.searchGameInpPlaceholderLen++
        );
        this.searchGameInpPlaceholderLen =
          this.searchGameInpPlaceholderLen >
          this.searchGameInpPlaceholder.length + 1
            ? 0
            : this.searchGameInpPlaceholderLen;
      }, 500);
    },

    // 搜索本板块
    changeSearchFlag() {
      if (this.keywordPost.length < 2) return this.$toast("最少两个关键字");
      this.flag = this.flag == 1 ? 0 : 1;
      this.searchFun();
    },

    // 搜索历史初始化
    searchHistoryInit() {
      let str = "";

      // 判断搜索模式
      if (this.model == 0) str = "searchPostHistory";
      else if (this.model == 1) str = "searchGameHistory";

      // 取值
      let data = JSON.parse(localStorage.getItem(str));

      // 判断搜索模式
      if (this.model == 0) this.searchPostHistoryList = data ? data : [];
      else if (this.model == 1) this.searchGameHistoryList = data ? data : [];

      console.log(data);
    },

    // 添加历史记录
    pushHistory() {
      if (this.model == 0) {
        let data = JSON.parse(localStorage.getItem("searchPostHistory"));
        if (!data) data = [];
        // 去重
        data = data.filter((k) => k != this.keywordPost);
        // 添加
        data.push(this.keywordPost);
        // this.searchPostHistoryList.push(this.keywordPost);
        // 存储
        localStorage.setItem("searchPostHistory", JSON.stringify(data));
        console.log("新增搜索历史记录 searchPostHistory", data);
      } else if (this.model == 1) {
        let data = JSON.parse(localStorage.getItem("searchGameHistory"));
        if (!data) data = [];
        // 去重
        data = data.filter((k) => k != this.keywordGame);
        // 添加
        data.push(this.keywordGame);
        // 存储
        localStorage.setItem("searchGameHistory", JSON.stringify(data));
        console.log("新增搜索历史记录 searchGameHistory", data);
      }
    },

    // 搜索按钮方法
    async searchFun() {
      // 在请求时
      this.$store.commit("showLoading");
      if (this.model == 0) {
        //贴子搜索模式
        if (this.active == 0 && this.keywordPost.length > 1) {
          await this.pushHistory();
          await this.PostListInit();
          this.isSearch = false;
        } else if (this.active == 1 && this.keywordUser.length > 1)
          this.$toast("暂未开放搜索用户");
        else this.$toast.fail("请检查关键字!");
      } else if (this.model == 1) {
        //游戏搜索模式
        if (this.keywordGame.length > 0) {
          await this.pushHistory();
          await this.GameListInit();
          this.isSearch = false;
        }
      }
      // 请求完成后
      this.$store.commit("hideLoading");
    },

    // 清空输入框方法
    clearInputFun() {
      this.keywordUser = "";
      this.keywordPost = "";
      this.keywordGame = "";
      this.isSearch = true; //切换为搜索状态
    },

    // 清空历史记录方法
    clearSearchListHistory(keyword) {
      if (keyword) {
        if (this.model == 0) {
          let data = JSON.parse(localStorage.getItem("searchPostHistory"));
          data = data.filter((k) => keyword != k);
          this.searchPostHistoryList = data;
          localStorage.setItem("searchPostHistory", JSON.stringify(data));
          this.$toast("删除完成\n" + keyword);
          console.log("删除完成", keyword);
        } else if (this.model == 1) {
          let data = JSON.parse(localStorage.getItem("searchGameHistory"));
          data = data.filter((k) => keyword != k);
          this.searchGameHistoryList = data;
          localStorage.setItem("searchGameHistory", JSON.stringify(data));
          this.$toast("删除完成\n" + keyword);
          console.log("删除完成", keyword);
        }
      } else {
        if (this.model == 0) {
          this.searchPostHistoryList = [];
          localStorage.setItem("searchPostHistory", JSON.stringify([]));
          this.$toast("清空完成");
          console.log("清空完成");
        } else if (this.model == 1) {
          this.searchGameHistoryList = [];
          localStorage.setItem("searchGameHistory", JSON.stringify([]));
          this.$toast("清空完成");
          console.log("清空完成");
        }
      }
    },

    // 贴子列表初始化
    async PostListInit() {
      let data = await getSearchPostList({
        start: 0,
        count: 20,
        cat_id: this.$route.query.cat_id,
        keyword: this.keywordPost,
        flag: this.flag,
      });
      this.$toast.success("拉取成功");
      this.PostList = data;
      console.log("请求到的数据 PostList =>", this.PostList);
    },

    // 游戏列表初始化
    async GameListInit() {
      let data = await getHomeJson();
      this.$toast.success("拉取成功");
      this.GameList = data.GameList.gameapps;
      console.log(
        "由于数据不够 将关键字替换成了 => 羊 所以请求到的数据  GameList =>",
        this.GameList
      );
    },

    // html代码转成字符
    HtmlToText(html) {
      let text = html;
      text = text.split("<text>").join("");
      text = text.split("</text>").join("");
      text = text.split("<image>").join("");
      text = text.split("</image>").join("");
      return text;
    },

    // 将很长的字符只取第一句
    TextToTitle(text) {
      let title = text;
      let arr = [];
      if (text.indexOf(" ") != -1) arr.push(text.indexOf(" "));
      if (text.indexOf("，") != -1) arr.push(text.indexOf("，"));
      if (text.indexOf(".") != -1) arr.push(text.indexOf("."));
      if (text.indexOf("。") != -1) arr.push(text.indexOf("。"));
      if (text.indexOf("；") != -1) arr.push(text.indexOf("；"));
      if (text.indexOf(";") != -1) arr.push(text.indexOf(";"));

      if (!arr.length) return title;

      arr = arr.sort((a, b) => a - b);
      return text.substring(0, arr[0]);
    },
  },
  created() {
    this.dataInit();
  },
  beforeDestroy() {
    this.searchGameInpInterval = null;
  },
  components: {
    TopTitleBar,
  },
  filters: {
    numToDate(val) {
      if (val > 1000000000) {
        let oldTime = parseInt(val);
        let newTime = new Date().getTime();
        let dTime = newTime - oldTime;
        if (dTime / 1000 < 60) return parseInt(dTime / 1000) + "秒前";
        else if (dTime / 1000 / 60 < 60)
          return parseInt(dTime / 1000 / 60) + "分前";
        else if (dTime / 1000 / 60 / 60 < 24)
          return parseInt(dTime / 1000 / 60 / 60) + "小时前";
        else if (dTime / 1000 / 60 / 60 / 24 < 30)
          return parseInt(dTime / 1000 / 60 / 60 / 24) + "天前";
        else if (dTime / 1000 / 60 / 60 / 24 / 30 < 12)
          return parseInt(dTime / 1000 / 60 / 60 / 24 / 30) + "月前";
        else return parseInt(dTime / 1000 / 60 / 60 / 24 / 30 / 12) + "年前";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.SearchView {
  min-height: 100%;
  .TopTitleBar {
    ::v-deep header {
      z-index: 9999;
    }
    .left {
      display: flex;
      align-items: center;
      .icon-xiangzuo1 {
        font-weight: bold;
        color: #fff;
        font-size: 22px;
      }
    }
    .middle {
      padding: 0 20px;
      height: 28px;
      overflow: hidden;
      position: relative;
      del.iconfont {
        position: absolute;
        right: 30px;
        top: 0;
        bottom: 0;
        margin: auto;
        text-decoration: none;
        width: 14px;
        font-size: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2px;
        height: 14px;
        background-color: #fff;
        border-radius: 50%;
        opacity: 0.5;
        color: #14c861;
      }
      .inp {
        border: 1px solid #ffffff;
        height: 28px;
        box-sizing: border-box;
        border-radius: 14px;
        input {
          display: block;
          background-color: transparent;
          width: 100%;
          line-height: 28px;
          padding: 0 15px;
          border: 0;
          box-sizing: border-box;
          font-size: 12px;
          color: #fff;
          &::-webkit-input-placeholder {
            color: #eee;
          }
        }
      }
    }
    .right {
      .icon-fangdajing {
        font-weight: bold;
        color: #fff;
        font-size: 22px;
        &.icon-xiaoxi {
          margin-left: 18px;
        }
      }
    }
  }

  main {
    margin-top: 8px;
    margin-top: 8px;
    margin-top: 0;
    padding: 0 12px;
    padding: 0;

    .box {
      background-color: rgba(255, 255, 255, 0.75);
      margin-bottom: 10px;
      padding: 8px;

      &:nth-child(1) {
        padding: 0;
      }

      .img {
        width: 83px;
        height: 83px;
        border-radius: 5px;
        overflow: hidden;
        margin-right: 8px;
      }
    }

    .name-icon {
      display: flex;
      padding-bottom: 8px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.5);
      padding: 0 13px;

      .icon {
        width: 61px;
        height: 61px;
        margin-right: 10px;

        img {
          position: relative;
          border-radius: 5px;
          bottom: 9px;
        }
      }

      h4 {
        height: 32px;
        line-height: 32px;
        color: #1c1c1c;
      }

      .level {
        height: 16px;
        line-height: 16px;
        text-align: center;
        color: #f4fefa;
        font-size: 12px;
        display: flex;
      }

      p {
        width: max-content;
        height: 16px;
        background-color: #12d364;
        border-radius: 4px;
        padding: 0 4px;

        span {
          display: inline-block;
          transform: scale(0.8);
        }

        &:last-child {
          background-color: #1dc8f0;
          margin-left: 5px;

          &::before {
            content: "";
            display: inline-block;
            width: 10px;
            height: 10px;
            background-size: cover;
            transform: scale(0.9);
            position: relative;
            top: 0;
          }
        }
      }

      .right {
        flex: 1;
      }

      .money {
        height: 22px;
        line-height: 22px;
        color: #656565;
        font-size: 12px;
        margin-top: 14px;

        span {
          color: #1e1e1e;
          margin-right: 5px;

          &:last-child {
            margin-left: 15px;
          }
        }
      }
    }

    .num {
      display: flex;
      flex-wrap: wrap;

      a {
        display: flex;
        align-items: center;
        flex-direction: column;
        justify-content: center;
        width: calc(100% / 3);
        text-align: center;
        height: 53px;
        font-size: 12px;
        position: relative;

        &::after {
          content: "";
          display: block;
          position: absolute;
          top: 0;
          bottom: 0;
          margin: auto;
          right: 0;
          width: 1px;
          height: 14px;
          background-color: #efefef;
        }

        &:nth-child(3n):after {
          content: none;
        }

        p {
          font-size: 14px;
          color: #000;
          margin-bottom: 4px;
        }

        small {
          color: #737373;
        }
      }
    }

    .head {
      h4 {
        height: 38px;
        line-height: 38px;
        color: #282828;
      }
    }

    .imgs {
      display: flex;
    }

    .info {
      p {
        height: 26px;
        line-height: 26px;
        margin-bottom: 3px;
        font-size: 14px;
        color: #868686;

        &:last-child {
          margin-bottom: 0;
        }

        span {
          color: #6a6a6a;
          margin-left: 12px;
        }
      }
    }

    .node-place {
      margin-top: 15px;
      padding-left: 4px;

      div {
        color: #1e1e1e;
        font-size: 15px;
        height: 33px;
        line-height: 33px;

        span {
          color: #00bf3f;
          margin-left: 11px;
        }
      }
    }

    .user {
      height: 70px;
      border-bottom: 1px solid #eaeaea;
      box-sizing: border-box;
      display: flex;
      padding: 12px;

      .icon {
        width: 46px;
        height: 46px;
        border-radius: 50%;
        overflow: hidden;
      }

      .text {
        flex: 1;
        margin: 0 10px;
      }

      .name {
        height: 25px;
        line-height: 25px;
        font-size: 15px;
        margin-bottom: 2px;
        color: #343434;
      }

      .age {
        background-color: #1dc8f0;
        height: 16px;
        line-height: 16px;
        border-radius: 3px;
        width: max-content;
        color: #fff;
        padding: 0 4px;

        span {
          display: inline-block;
          transform: scale(0.7);
          margin-left: -4px;
        }

        &::before {
          content: "";
          display: inline-block;
          background-size: 10px 81px;
          width: 10px;
          height: 11px;
        }
      }

      p {
        display: block;
        width: 65px;
        height: 25px;
        box-sizing: border-box;
        border: 1px solid #bdbdbd;
        color: #bdbdbd;
        font-size: 12px;
        text-align: center;
        line-height: 25px;
        border-radius: 5px;
        align-self: center;
      }

      &.con {
        p {
          border-color: #0cc85c;
          color: #0cc85c;
        }
      }

      &.woman {
        .age {
          background-color: #f452a2;

          &::before {
            background-size: 10px 81px;
            width: 8px;
            height: 11px;
          }
        }
      }
    }

    .msg-item {
      display: flex;
      padding: 12px;
      border-bottom: 1px solid #e6e6e6;

      &:active {
        opacity: 0.9;
        box-shadow: 0 0 100px 0 inset rgba(0, 0, 0, 0.1);
      }

      .icon {
        width: 46px;
        height: 46px;
        border-radius: 50%;
        overflow: hidden;
        flex-shrink: 0;
      }

      .text {
        flex: 1;
        max-width: calc(100% - 56px);
        margin-left: 10px;
      }

      .title {
        display: flex;
        justify-content: space-between;
        margin-bottom: 2px;

        span {
          display: block;
          color: #343434;
          height: 22px;
          line-height: 22px;
          font-size: 15px;
        }

        small {
          font-size: 12px;
          color: #0cc85c;
        }
      }

      .age {
        background-color: #1dc8f0;
        height: 16px;
        line-height: 16px;
        border-radius: 3px;
        width: max-content;
        color: #fff;
        padding: 0 4px;

        span {
          display: block;
          font-size: 12px;
          display: flex;
          align-items: center;

          &::before {
            display: block;
            margin-right: 2px;
          }
        }
      }

      .woman {
        background-color: #f452a2;
      }

      .time {
        font-size: 12px;
        color: #bebebe;
        height: 28px;
        line-height: 28px;
        margin-bottom: 5px;
      }

      .reply {
        background-color: #f0f0f0;
        padding: 5px 10px;
        border-radius: 4px;

        h5 {
          font-weight: normal;
          color: #969696;
          height: 31px;
          line-height: 31px;
        }

        p {
          color: #646464;
          line-height: 20px;
          padding: 4px 0 5px;
          font-size: 15px;
        }
      }

      .content {
        color: #323232;
        line-height: 20px;
        margin: 11px 0;
        font-size: 15px;
      }

      .origin {
        border: 1px solid #e0e0e0;
      }
    }

    .post-item {
      padding: 13px 0;
      display: flex;
      border-bottom: 1px solid #dddddd;

      .icon {
        width: 91px;
        height: 91px;
        border-radius: 5px;
        overflow: hidden;
      }

      .text {
        flex: 1;
        margin-left: 8px;
      }

      .title {
        line-height: 21px;
        color: #0e0e0e;
        font-size: 15px;
        margin-bottom: 5px;
      }

      .content {
        height: 42px;
        line-height: 14px;
        color: #646464;
        font-size: 12px;
        margin-bottom: 11px;
      }

      .info {
        display: flex;
        justify-content: space-between;

        .name {
          small {
            color: #969696;
          }
        }

        .time {
          small {
            color: #cccccc;
          }
        }
      }

      .seek {
        i {
          content: "";
          display: inline-block;
          background-size: 69px 13px;
          width: 16px;
          height: 11px;
          position: relative;
          vertical-align: middle;
        }
      }

      .msg {
        margin-left: 5px;

        i {
          content: "";
          display: inline-block;
          background-size: 69px 13px;
          width: 13px;
          height: 13px;
          position: relative;
          vertical-align: middle;
        }
      }
    }

    & > div {
      display: block;
    }

    .icon-info {
      display: flex;
      padding: 12px;
      background-color: #fff;

      .img {
        width: 72px;
        height: 72px;
        border-radius: 5px;
        overflow: hidden;
        margin-right: 12px;
      }

      .info {
        flex: 1;

        h1 {
          height: 21px;
          line-height: 21px;
          font-size: 15px;
          color: #0e0e0e;
          margin: 0;
        }

        p {
          color: #969696;
          font-size: 12px;
          margin-bottom: 0;

          span {
            color: #14ca61;
            margin-right: 12px;
            margin-left: 0;
          }
        }
      }
    }

    .icons {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .left {
        display: flex;
      }

      .icon {
        width: 25px;
        height: 25px;
        border-radius: 50%;
        overflow: hidden;
        margin-right: 5px;
      }

      .more {
        background-size: 21px 5px;
        width: 21px;
        height: 5px;
        justify-items: flex-end;
      }
    }
  }

  .wrap {
    background-color: #f0f0f0;

    .head {
      display: flex;
      justify-content: space-between;
      box-sizing: border-box;
      border-bottom: 1px solid #e0e0e0;
      padding: 0 12px;
      background-color: #fff;

      h1 {
        margin: 0;
        font-size: 15px;
        height: 38px;
        line-height: 38px;
        color: #0e0e0e;
        font-weight: normal;
      }

      .clear {
        color: #0cc85c;
        font-size: 13px;
        line-height: 37px;
      }
    }

    .body {
      .history-item {
        display: flex;
        height: 46px;
        box-sizing: border-box;
        border: 1px solid #e0e0e0;
        align-items: center;
        padding: 0 12px;
        background-color: #fff;

        &:last-child {
          border-bottom-width: 0;
        }

        em {
          display: block;
          background-size: 351px 16px;
          width: 15px;
          height: 15px;
        }

        span {
          display: block;
          flex: 1;
          color: #969696;
          margin: 0 8px;
          font-size: 15px;
        }

        del {
          display: block;
          background-size: 351px 16px;
          width: 10px;
          height: 10px;
        }
      }
    }
  }

  .box {
    padding: 0 12px;

    .item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 74px;
      box-sizing: border-box;
      border-bottom: 1px solid #eaeaea;
      position: relative;
    }

    .img {
      width: 49px;
      height: 49px;
    }

    .title {
      width: calc(100% - 59px);
      box-sizing: border-box;
      padding-right: 25px;
      height: 49px;
      line-height: 49px;
      color: #3e3e3e;

      h4 {
        font-weight: normal;
      }
    }

    i {
      position: absolute;
      right: 0;
      top: 0;
      bottom: 0;
      margin: auto;
      width: 9px;
      height: 17px;
      background-size: cover;
    }
  }

  main .post-item .info .left,
  main .post-item .info .right {
    display: flex;
    font-size: 12px;
    height: 12px;
    line-height: 12px;
  }

  main .post-item .info .left small,
  main .post-item .info .right small {
    display: inline-block;
    transform: scale(0.9);
    color: #3e3e3e;
  }

  header .left,
  header .right {
    display: flex;
  }

  .talent {
    display: flex;
    background-color: #fafafa;
    height: 42px;
    align-items: center;
    box-sizing: border-box;
    border-top: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    background-color: #fff;

    a {
      display: block;
      flex: 1;
      height: 22px;
      line-height: 22px;
      text-align: center;
      border-right: 1px solid #f0f0f0;
      color: #969696;
      font-size: 14px;

      i {
        display: inline-block;
        background-size: 237px 42px;
        width: 22px;
        height: 22px;
        vertical-align: -5px;
        margin-right: 5px;
      }

      &:nth-child(2) {
        i {
          background-size: 237px 42px;
          width: 21px;
          height: 21px;
        }
      }
    }
  }

  .announce {
    padding: 0 12px;
    margin-bottom: 10px;
    background-color: #fff;

    a {
      display: block;
      width: 100%;
      font-size: 15px;
      color: #0e0e0e;
      height: 45px;
      line-height: 45px;
      border-bottom: 1px solid #dddddd;

      &:last-child {
        border-bottom-width: 0;
      }

      em {
        font-style: normal;
        display: inline-block;
        height: 14px;
        line-height: 14px;
        font-size: 12px;
        color: #fff;
        border-radius: 2px;
      }

      .red {
        background-color: #ff3e62;
      }

      .yellow {
        background-color: #fb9644;
      }

      span {
        display: inline-block;
        transform: scale(0.8);
        position: relative;
        bottom: 1px;
      }
    }
  }

  .post-mag-box {
    background-color: #fff;

    .head {
      display: flex;
      height: 42px;
      line-height: 42px;
      overflow-x: scroll;
      font-size: 15px;
      color: #646464;

      p {
        height: 42px;
        box-sizing: border-box;
        border-bottom: 1px solid #e0e0e0;
        white-space: nowrap;
        padding: 0 12px;
      }

      .con {
        color: #14ca61;
        position: relative;

        &::after {
          content: "";
          display: block;
          position: absolute;
          height: 2px;
          left: 0;
          right: 0;
          bottom: -1px;
          width: calc(100% - 24px);
          margin: auto;
          background-color: #0cc85c;
        }
      }

      &::-webkit-scrollbar {
        width: 0;
        height: 0;
      }

      &::-webkit-scrollbar-thumb {
        width: 0;
        height: 0;
      }
    }

    .body {
      padding: 0 12px;
    }
  }

  ::v-deep .van-sticky {
    border-bottom: 1px solid #eee;
    .van-tabs__line {
      bottom: 20px;
    }
  }
  ::v-deep .van-tabs__content {
    .search-post-box {
      margin-bottom: 10px;
      background-color: #fff;
      padding: 0 12px;
      border-top: 2px solid #eee;
      height: 37px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      &:active {
        opacity: 0.9;
        box-shadow: 0 0 37px 0 inset rgba($color: #aaa, $alpha: 0.2);
      }
      p {
        height: 37px;
        line-height: 37px;
        font-size: 15px;
        color: #333333;
        text-align: left;
      }
      .iconfont {
        color: #dbdbdb;
      }
    }
    hr {
      margin: 0;
      border-left-width: 0;
      border-right-width: 0;
      border-bottom-width: 0;
      border-style: dashed;
      border-color: #13cd62;
      border-top-width: 2px;
    }
  }
  .wrap {
    padding-top: 0;
    .head {
      .right {
        .clear {
          display: flex;
          align-items: center;
          &::before {
            margin-right: 2px;
            font-size: 20px;
          }
        }
      }
    }
    .body {
      .history-item {
        align-items: center;
        &:active {
          opacity: 0.9;
          box-shadow: 0 0 46px 0 inset rgba($color: #aaa, $alpha: 0.2);
        }
        del,
        em {
          text-decoration: none;
          color: #dbdbdb;
          width: auto;
          height: auto;
        }
        em {
          font-size: 18px;
        }
      }
    }

    .post-item {
      padding: 13px 0;
      display: flex;
      border-bottom: 1px solid #dddddd;

      .icon {
        width: 91px;
        height: 91px;
        border-radius: 5px;
        overflow: hidden;
      }

      .text {
        flex: 1;
        margin-left: 8px;
      }

      .title {
        line-height: 21px;
        color: #0e0e0e;
        font-size: 15px;
        margin-bottom: 5px;
      }

      .content {
        height: 42px;
        line-height: 14px;
        color: #646464;
        font-size: 12px;
        margin-bottom: 11px;
      }

      .info {
        display: flex;
        justify-content: space-between;

        .left,
        .right {
          display: flex;
          align-items: center;
        }

        .name {
          small {
            color: #969696;
          }
        }

        .time {
          small {
            color: #cccccc;
          }
        }
      }

      .seek {
        i {
          content: "";
          display: inline-block;
          background-size: 69px 13px;
          width: 16px;
          height: 11px;
          position: relative;
          vertical-align: middle;
        }
      }

      .msg {
        margin-left: 5px;

        i {
          content: "";
          display: inline-block;
          background-size: 69px 13px;
          width: 13px;
          height: 13px;
          position: relative;
          vertical-align: middle;
        }
      }
    }
    .post-mag-box {
      .body {
        padding: 0;
        .post-item-box {
          padding: 0 12px;

          &:active {
            opacity: 0.9;
            box-shadow: 0 0 100px 0 inset rgba($color: #000000, $alpha: 0.2);
          }

          &:last-child {
            .post-item {
              border-bottom-width: 0;
            }
          }

          .post-item {
            padding: 0 0 10px;
            border-bottom: 1px solid #dedede;

            .text {
              width: 100%;
              .title {
                background-color: transparent;
              }
              .content {
                height: 48px;
                line-height: 16px;
              }
              .info {
                .right {
                  .iconfont {
                    font-size: 12px;
                    &::before {
                      margin-right: 3px;
                    }
                  }
                }
              }
            }

            // 只有一张图
            &.one-pic {
              padding-top: 8px;
              .content {
                color: #646464;
                margin-bottom: 7px;
                .title {
                  padding-left: 0;
                  padding-right: 0;
                }
              }
            }

            // 一张图都没
            &.none-pic {
              .text {
                margin-left: 0;
                width: 100%;
                .title {
                  max-height: 42px;
                  padding: 0;
                  padding-top: 8px;
                }
                .content {
                  max-height: 28px;
                  height: auto;
                }
              }
            }

            // 两张图以上
            &.many-pic {
              .text {
                padding-top: 8px;
                margin-left: 0;

                .content {
                  height: auto;
                  max-height: 48px;
                }

                .imgs {
                  height: 110px;
                  border-radius: 5px;
                  display: flex;
                  overflow: hidden;
                  position: relative;
                  margin-bottom: 8px;
                  .img {
                    width: 110px;
                    height: 110px;
                    overflow: hidden;
                    border-radius: 5px;
                    margin-right: calc((100% - 330px) / 2);
                    &:nth-child(3) {
                      margin-right: 0;
                    }
                  }
                  b {
                    position: absolute;
                    right: 0;
                    bottom: 0;
                    font-size: 12px;
                    color: #fff;
                    width: max-content;
                    height: 18px;
                    line-height: 18px;
                    display: block;
                    padding: 0 4px;
                    background-color: rgba($color: #000000, $alpha: 0.2);
                    border-radius: 5px 0;
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  .hot-game {
    // position: fixed;
    // top: 60px;
    padding: 10px 12px 0;
    background-color: #fff;
    margin-bottom: 10px;

    .game-head {
      height: 24px;
      line-height: 24px;
      font-size: 15px;
      color: #323232;
    }

    .game-body {
      display: flex;
      flex-wrap: wrap;
      counter-reset: num 0;

      p {
        display: flex;
        width: 50%;
        font-size: 14px;
        height: 36px;
        line-height: 36px;
        color: #717171;
        &:active {
          box-shadow: 0 0 36px 0 inset rgba(0, 0, 0, 0.1);
        }

        &.con {
          color: #00bfff;
        }
        em {
          display: block;
          width: 24px;
          font-style: normal;
        }
      }
    }
  }

  .item-flag-0 {
    background-color: #fff;
    padding: 0 12px;
    border-bottom: 1px solid #dddddd;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    &:active {
      box-shadow: 0 0 75px 0 inset rgba(0, 0, 0, 0.2);
      opacity: 0.9;
    }
    .left {
      display: flex;
      max-width: calc(100% - 61px - 10px);
      .img {
        width: 51px;
        height: 51px;
        margin-right: 10px;
        border-radius: 6px;
        overflow: hidden;
      }
      .text {
        h5 {
          height: 26px;
          height: 26px;
          line-height: 26px;
        }
        p {
          height: 24px;
          line-height: 24px;
          color: #969696;
          font-size: 13px;
        }
      }
    }
    .right {
      a {
        display: block;
        border-radius: 12px;
        width: 61px;
        height: 24px;
        line-height: 26px;
        text-align: center;
        font-size: 13px;
        &.download {
          border: 1px solid #20c250;
          color: #20c250;
        }
        &.play {
          border: 1px solid #3f51b5;
          color: #3f51b5;
        }
      }
    }
  }
}
</style>